package com.atgm.mall.gmmallclub.controller;

import com.atgm.common.utils.PageUtils;
import com.atgm.common.utils.R;
import com.atgm.mall.gmmallclub.entity.ArticleCommentEntity;
import com.atgm.mall.gmmallclub.service.ArticleCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("gmmallclub/articlecomment")
public class ArticleCommentController {

    @Autowired
    private ArticleCommentService articleCommentService;

    @GetMapping("/getCommentInfo")
    public R getCommentInfoByArticleId(@RequestParam Map<String, Object> params) {
        PageUtils pageUtils = articleCommentService.queryCommentInfoByArticleId(params);
        return R.ok().setData(pageUtils);
    }

    /**
     * 保存评论信息
     *
     * @param articleCommentEntity
     * @return
     */
    @PostMapping("/addCommentInfo")
    public R addCommentInfo(@RequestBody ArticleCommentEntity articleCommentEntity) {
        articleCommentService.saveArticleCommentInfo(articleCommentEntity);
        return R.ok();
    }

    @GetMapping("/updateThumbsCount/{id}/{count}")
    public R updateThumbsCount(@PathVariable("id") Long id, @PathVariable("count") Integer count) {
        articleCommentService.updateThumbsCountInfo(id, count);
        return R.ok();
    }

}
